#ifndef BASICRENDERFUNCTIONS_H
#define BASICRENDERFUNCTIONS_H
#include "StompedReality/Base.h"
#include "StompedReality/Core.h"
#include "StompedReality/Core/Graphics/RenderFunction.h"
#include "StompedReality/Math/Vector2.h"
#include <functional>
namespace StompedReality
{

namespace Graphics
{

namespace Functions
{

/*!
 *
 * \author	Stefan Kazalski
 *
 * \brief	Translate rotate Render function.
 *
 *			Commands: (glPushMatrix) -> glTranslate -> glRotate
 */
class DLL_EXPORT TranslateRotate : public StompedReality::Graphics::RenderFunction {
 public:

  //! \brief	Translation.
  StompedReality::Math::Vector2 Translation;

  //! \brief	Depth.
  float Depth;

  //! \brief	Rotation.
  float Rotation;

  //! \brief	PushMatrix?
  bool PushMatrix;

  //! \brief	Copy Delegate.
  std::function<void( TranslateRotate* )> CopyDelegate;

  //! \brief	Constructor.
  //! \param	renderOrder		Rendered at position.
  //! \param	push			PushMatrix flag.
  //! \param	isStatic		Statis or not (Default: true).
  TranslateRotate ( unsigned char renderOrder, bool push = true, bool isStatic = true );

  //! \brief	Destructor.
  ~TranslateRotate ( );

  //! \brief	Copies render data.
  void CopyRenderData ( );

  //! \brief	Draw.
  //!			Commands: (glPushMatrix) -> glTranslate -> glRotate
  //! \param	game	The game.
  void Draw ( StompedReality::IGame* game );
};

/*!
 *
 * \author	Stefan Kazalski
 *
 * \brief	Pop matrix Render function.
 *
 *			Commands: glPopMatrix
 */
class DLL_EXPORT PopMatrix : public StompedReality::Graphics::RenderFunction {
 public:

  //! \brief	Constructor.
  //! \param	renderOrder		Rendered at position.
  PopMatrix ( unsigned char renderOrder ) : StompedReality::Graphics::RenderFunction ( renderOrder, true ) {
  }

  //! \brief	Destructor.
  ~PopMatrix ( ) {
  }

  //! \brief	Copies render data.
  //!    Does nothing.
  void CopyRenderData ( );

  //! \brief	Draw.
  //!			Commands: glPopMatrix.
  //! \param	game	The game.
  void Draw ( StompedReality::IGame* game );
};

/*!
 *
 * \author	Stefan Kazalski
 *
 * \brief	Draw patch function.
 *
 *			Commands: glTranslate -> draw patch.
 */
class DLL_EXPORT RenderPatch : public StompedReality::Graphics::RenderFunction {
 public:

  //! \brief	Offset
  StompedReality::Math::Vector2 Offset;

  //! \brief	gl binding of patch vbo
  ID PatchBinding;

  //! \brief	gl binding of texture
  ID TextureBinding;

  //! \brief	Copy Delegate.
  std::function<void( RenderPatch* )> CopyDelegate;

  //! \brief	Constructor.
  //! \param	renderOrder		Rendered at position.
  RenderPatch ( unsigned char renderOrder );

  //! \brief	Destructor.
  ~RenderPatch ( ) {
  }

  //! \brief	Copies render data.
  void CopyRenderData ( );

  //! \brief	Draw.
  //!			Commands: glTranslate -> draw patch.
  void Draw ( StompedReality::IGame* game );
};

/*!
 *
 * \author	Stefan Kazalski
 *
 * \brief	Draw rectangle function.
 *
 *    Draws rectangle of given half size with given center.
 *			Commands: glTranslate -> draw rectangle.
 */
class DLL_EXPORT RenderRectangle : public StompedReality::Graphics::RenderFunction {
 public:

  //! \brief	Center.
  StompedReality::Math::Vector2 Center;

  //! \brief	Half size of rectangle.
  StompedReality::Math::Vector2 HalfSize;

  //! \brief	Copy Delegate.
  std::function<void( RenderRectangle* )> CopyDelegate;

  //! \brief	Constructor.
  //! \param	renderOrder		Rendered at position.
  RenderRectangle ( unsigned char renderOrder );

  //! \brief	Destructor.
  ~RenderRectangle ( ) {
  }

  //! \brief	Copies render data.
  void CopyRenderData ( );

  //! \brief	Draw.
  //!			Commands: glTranslate -> draw rectangle.
  void Draw ( StompedReality::IGame* game );
};

}

}

}

#endif // BASICRENDERFUNCTIONS_H
